package com.laizhenghua.share.device.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.laizhenghua.share.device.domain.entity.CabinetSlot;
import com.laizhenghua.share.device.mapper.CabinetSlotMapper;
import com.laizhenghua.share.device.service.ICabinetSlotService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TODO
 *
 * @Description
 * @Author laizh
 * @Date 2025/10/19 21:22
 **/
@Slf4j
@Service
public class ICabinetSlotServiceImpl extends ServiceImpl<CabinetSlotMapper, CabinetSlot> implements ICabinetSlotService {
    @Override
    public CabinetSlot getBtSlotNo(Long id, String slotNo) {
        LambdaQueryWrapper<CabinetSlot> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CabinetSlot::getCabinetId, id);
        queryWrapper.eq(CabinetSlot::getSlotNo, slotNo);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public List<CabinetSlot> listCabinetSlotByCabinetId(Long cabinetId) {
        LambdaQueryWrapper<CabinetSlot> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CabinetSlot::getCabinetId, cabinetId);
        queryWrapper.orderByAsc(CabinetSlot::getId);
        return baseMapper.selectList(queryWrapper);
    }
}
